#if !USE_CONSOLE

#ifndef TREE_WIDGET_H
#define TREE_WIDGET_H

#include <QTreeWidget>
#include <QString>

class Scene;
class TreeItem;
class Object;
class Light;
class GLWidget;

class TreeWidget : public QTreeWidget {
	Q_OBJECT

    public:
        TreeWidget(const QString &, GLWidget *_glWidget, QWidget * = 0);
        ~TreeWidget();

        void addObject(Object *);
        void addLight(Light *);

        void updateObjects(const std::vector<Object *> *, Scene *);
        void updateLights(Scene *);

    signals:
        void updateActionsFromSelection(int);
        void updateActionsFromEditing(int);
        void updateActionsFromChanging();
        void updateActionsFromChanging(int);
        void updateActionsFromLight(int, int);
        void deleteObjectSignal(Object *);
//        void deleteLightSignal(Light *);
        void addObjectSignal(Object *);
//        void addLightSignal(Light *);
//        void doneEditing();

    public slots:
        void deleteItens(Scene *);

        void duplicateObject(Scene *);
//        void edited(){emit doneEditing();};
        void itemSelectionChangedSlot();
        void itemDoubleClickedSlot(QTreeWidgetItem *, int);

        void unionOperation(Scene *);
        void intersectionOperation(Scene *);
        void differenceOperation(Scene *);
        void translateOperation();
        void rotateOperation();
        void scaleOperation();

        void deleteObjectSlot(Object *_o){emit deleteObjectSignal(_o);};
        void addObjectSlot(Object *_o){emit addObjectSignal(_o);};

        void updateActionsFromLightSlot() {emit updateActionsFromLight(invisibleRootItem()->childCount(), previousSelected.size());};
        void updateActionsFromEditingSlot() {emit updateActionsFromEditing(previousSelected.size());};
        void updateActionsFromChangingSlot() {emit updateActionsFromChanging(previousSelected.size());};

    private:
        bool inOperation;
        GLWidget *glWidget;

        QList<TreeItem *> previousSelected;

        int addTreeItem(Object *, QTreeWidgetItem *, bool, Scene *);

        void duplicateObject(QTreeWidgetItem *, Object *);
        Object *duplicateObject(Object *, Scene *);

        std::vector<Object*> preOperation(QTreeWidgetItem **);
        void postOperation(QTreeWidgetItem *, Object *, Scene *);
};

#endif

#endif //!USE_CONSOLE
